package com.socool;

import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.Button;

import com.socool.facebook.Act_Login_FB;
import com.socool.manager.Manager_Shared;
import com.socool.signup.Act_SignUpSelect;

public class Act_Login extends Activity {

	
	Button facebookLogin;
	Button facebookSignup;
	
	private static final int FB_Login = 0; 

	ProgressDialog progressDialog;
	final static String LOG_TAG="test";
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		Log.d(LOG_TAG, "["+getLocalClassName()+"]"+"onCreate");
	
		
		 
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		super.onCreate(savedInstanceState);
		setContentView(R.layout.act_login_main);
		
		facebookLogin = (Button)findViewById(R.id.facebookLogin);
		facebookSignup = (Button)findViewById(R.id.signup);
		
		facebookLogin.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View arg0) {

				
				  Intent intent = new Intent(Act_Login.this, Act_Login_FB.class);
				  startActivityForResult(intent, FB_Login);
				
					 
				  
				  //startActivityForResult사용을 위함
				  /*
				  intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
				  startActivityForResult(intent,FB_Login);
			     */
				
			}
		});
		
		facebookSignup.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				Intent i = new Intent(Act_Login.this, Act_SignUpSelect.class);
				
				
				startActivity(i);
				 overridePendingTransition(R.anim.fade,R.anim.hold);
				 
				
			}
		});
	
		
	}
	
	
	public void onActivityResult(int requestCode, int resultCode, Intent intent){
		Log.d(LOG_TAG, "["+getLocalClassName()+"]"+"onActivityResult");
		super.onActivityResult(requestCode, resultCode, intent);
		 
		switch(requestCode){
		case FB_Login: // requestCode가 FB_Login 케이스
		if(resultCode == RESULT_OK){ //B_ACTIVITY에서 넘겨진 resultCode가 OK일때만 실행
		//int data = intent.getExtras().getInt("data"); //등과 같이 사용할 수 있는데, 여기서 getXXX()안에 들어있는 파라메터는 꾸러미 속 데이터의 이름표라고 보면된다.
		//Log.d("test", "data: "+data);

			// 로그인모드를 저장한다.
			Manager_Shared mManagerShared = new Manager_Shared(this);
			mManagerShared.setPref_Loginstatus("facebook");
			
		Intent i = new Intent(this, HomeActivity.class);
		
		
		startActivity(i);
		 overridePendingTransition(R.anim.fade,R.anim.hold);
		 finish();
		
		}
		break;
		}
		}


		

	

}